<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>boost/python/docstring_options.hpp</title>
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="Boost.Python Reference Manual">
<link rel="up" href="../high_level_components.html" title="Chapter 2. High Level Components">
<link rel="prev" href="boost_python_def_visitor_hpp.html" title="boost/python/def_visitor.hpp">
<link rel="next" href="boost_python_enum_hpp.html" title="boost/python/enum.hpp">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../../images/boost.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost_python_def_visitor_hpp.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../high_level_components.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="boost_python_enum_hpp.html"><img src="../../images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="high_level_components.boost_python_docstring_options_h"></a><a class="link" href="boost_python_docstring_options_h.html" title="boost/python/docstring_options.hpp">boost/python/docstring_options.hpp</a>
</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.class_docstring_options">Class
        <code class="computeroutput"><span class="identifier">docstring_options</span></code></a></span></dt>
<dt><span class="section"><a href="boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.class_dostring_options_construct">Class
        dostring_options constructors</a></span></dt>
<dt><span class="section"><a href="boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.class_docstring_options_destruct">Class
        docstring_options destructor</a></span></dt>
<dt><span class="section"><a href="boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.class_docstring_options_modifier">Class
        <code class="computeroutput"><span class="identifier">docstring_options</span></code> modifier
        functions</a></span></dt>
<dt><span class="section"><a href="boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.example">Example</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="high_level_components.boost_python_docstring_options_h.introduction"></a><a class="link" href="boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.introduction" title="Introduction">Introduction</a>
</h3></div></div></div>
<p>
          Boost.Python supports user-defined docstrings with automatic appending
          of C++ signatures. These features are enabled by default. The class docstring_options
          is available to selectively suppress the user-defined docstrings, signatures,
          or both.
        </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="high_level_components.boost_python_docstring_options_h.class_docstring_options"></a><a class="link" href="boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.class_docstring_options" title="Class docstring_options">Class
        <code class="computeroutput"><span class="identifier">docstring_options</span></code></a>
</h3></div></div></div>
<p>
          Controls the appearance of docstrings of wrapped functions and member functions
          for the life-time of the instance. The instances are noncopyable to eliminate
          the possibility of surprising side effects.
        </p>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">python</span> <span class="special">{</span>

  <span class="keyword">class</span> <span class="identifier">docstring_options</span> <span class="special">:</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">noncopyable</span>
  <span class="special">{</span>
  <span class="keyword">public</span><span class="special">:</span>
    <span class="identifier">docstring_options</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">show_all</span><span class="special">=</span><span class="keyword">true</span><span class="special">);</span>
    <span class="identifier">docstring_options</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">show_user_defined</span><span class="special">,</span> <span class="keyword">bool</span> <span class="identifier">show_signatures</span><span class="special">);</span>
    <span class="identifier">docstring_options</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">show_user_defined</span><span class="special">,</span> <span class="keyword">bool</span> <span class="identifier">show_py_signatures</span><span class="special">,</span> <span class="keyword">bool</span> <span class="identifier">show_cpp_signatures</span><span class="special">);</span>
    <span class="special">~</span><span class="identifier">docstring_options</span><span class="special">();</span>
    <span class="keyword">void</span> <span class="identifier">disable_user_defined</span><span class="special">();</span>
    <span class="keyword">void</span> <span class="identifier">enable_user_defined</span><span class="special">();</span>
    <span class="keyword">void</span> <span class="identifier">disable_signatures</span><span class="special">();</span>
    <span class="keyword">void</span> <span class="identifier">enable_signatures</span><span class="special">();</span>
    <span class="keyword">void</span> <span class="identifier">disable_py_signatures</span><span class="special">();</span>
    <span class="keyword">void</span> <span class="identifier">enable_py_signatures</span><span class="special">();</span>
    <span class="keyword">void</span> <span class="identifier">disable_cpp_signatures</span><span class="special">();</span>
    <span class="keyword">void</span> <span class="identifier">enable_cpp_signatures</span><span class="special">();</span>
    <span class="keyword">void</span> <span class="identifier">disable_all</span><span class="special">();</span>
    <span class="keyword">void</span> <span class="identifier">enable_all</span><span class="special">();</span>
  <span class="special">};</span>
<span class="special">}}</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="high_level_components.boost_python_docstring_options_h.class_dostring_options_construct"></a><a class="link" href="boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.class_dostring_options_construct" title="Class dostring_options constructors">Class
        dostring_options constructors</a>
</h3></div></div></div>
<pre class="programlisting"><span class="identifier">docstring_options</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">show_all</span><span class="special">=</span><span class="keyword">true</span><span class="special">);</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Effects</span></dt>
<dd><p>
                Constructs a docstring_options object which controls the appearance
                of function and member-function docstrings defined in the code that
                follows. If show_all is true, both the user-defined docstrings and
                the automatically generated Python and C++ signatures are shown.
                If show_all is false the <code class="computeroutput"><span class="identifier">__doc__</span></code>
                attributes are <code class="computeroutput"><span class="identifier">None</span></code>.
              </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="identifier">docstring_options</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">show_user_defined</span><span class="special">,</span> <span class="keyword">bool</span> <span class="identifier">show_signatures</span><span class="special">);</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Effects</span></dt>
<dd><p>
                Constructs a <code class="computeroutput"><span class="identifier">docstring_options</span></code>
                object which controls the appearance of function and member-function
                docstrings defined in the code that follows. Iff <code class="computeroutput"><span class="identifier">show_user_defined</span></code>
                is <code class="computeroutput"><span class="keyword">true</span></code>, the user-defined
                docstrings are shown. Iff <code class="computeroutput"><span class="identifier">show_signatures</span></code>
                is <code class="computeroutput"><span class="keyword">true</span></code>, Python and
                C++ signatures are automatically added. If both <code class="computeroutput"><span class="identifier">show_user_defined</span></code>
                and <code class="computeroutput"><span class="identifier">show_signatures</span></code>
                are <code class="computeroutput"><span class="keyword">false</span></code>, the <code class="computeroutput"><span class="identifier">__doc__</span></code> attributes are <code class="computeroutput"><span class="identifier">None</span></code>.
              </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="identifier">docstring_options</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">show_user_defined</span><span class="special">,</span> <span class="keyword">bool</span> <span class="identifier">show_py_signatures</span><span class="special">,</span> <span class="keyword">bool</span> <span class="identifier">show_cpp_signatures</span><span class="special">);</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Effects</span></dt>
<dd><p>
                Constructs a <code class="computeroutput"><span class="identifier">docstring_options</span></code>
                object which controls the appearance of function and member-function
                docstrings defined in the code that follows. Iff <code class="computeroutput"><span class="identifier">show_user_defined</span></code>
                is <code class="computeroutput"><span class="keyword">true</span></code>, the user-defined
                docstrings are shown. Iff <code class="computeroutput"><span class="identifier">show_py_signatures</span></code>
                is <code class="computeroutput"><span class="keyword">true</span></code>, Python signatures
                are automatically added. Iff <code class="computeroutput"><span class="identifier">show_cpp_signatures</span></code>
                is true, C++ signatures are automatically added. If all parameters
                are <code class="computeroutput"><span class="keyword">false</span></code>, the <code class="computeroutput"><span class="identifier">__doc__</span></code> attributes are <code class="computeroutput"><span class="identifier">None</span></code>.
              </p></dd>
</dl>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="high_level_components.boost_python_docstring_options_h.class_docstring_options_destruct"></a><a class="link" href="boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.class_docstring_options_destruct" title="Class docstring_options destructor">Class
        docstring_options destructor</a>
</h3></div></div></div>
<pre class="programlisting"><span class="special">~</span><span class="identifier">docstring_options</span><span class="special">();</span></pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Effects</span></dt>
<dd><p>
                Restores the previous state of the docstring options. In particular,
                if <code class="computeroutput"><span class="identifier">docstring_options</span></code>
                instances are in nested C++ scopes the settings effective in the
                enclosing scope are restored. If the last <code class="computeroutput"><span class="identifier">docstring_options</span></code>
                instance goes out of scope the default "all on" settings
                are restored.
              </p></dd>
</dl>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="high_level_components.boost_python_docstring_options_h.class_docstring_options_modifier"></a><a class="link" href="boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.class_docstring_options_modifier" title="Class docstring_options modifier functions">Class
        <code class="computeroutput"><span class="identifier">docstring_options</span></code> modifier
        functions</a>
</h3></div></div></div>
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">disable_user_defined</span><span class="special">();</span>
<span class="keyword">void</span> <span class="identifier">enable_user_defined</span><span class="special">();</span>
<span class="keyword">void</span> <span class="identifier">disable_signatures</span><span class="special">();</span>
<span class="keyword">void</span> <span class="identifier">enable_signatures</span><span class="special">();</span>
<span class="keyword">void</span> <span class="identifier">disable_py_signatures</span><span class="special">();</span>
<span class="keyword">void</span> <span class="identifier">enable_py_signatures</span><span class="special">();</span>
<span class="keyword">void</span> <span class="identifier">disable_cpp_signatures</span><span class="special">();</span>
<span class="keyword">void</span> <span class="identifier">enable_cpp_signatures</span><span class="special">();</span>
<span class="keyword">void</span> <span class="identifier">disable_all</span><span class="special">();</span>
<span class="keyword">void</span> <span class="identifier">enable_all</span><span class="special">();</span>
</pre>
<p>
          These member functions dynamically change the appearance of docstrings
          in the code that follows. The <code class="computeroutput"><span class="special">*</span><span class="identifier">_user_defined</span><span class="special">()</span></code>
          and <code class="computeroutput"><span class="special">*</span><span class="identifier">_signatures</span><span class="special">()</span></code> member functions are provided for fine-grained
          control. The <code class="computeroutput"><span class="special">*</span><span class="identifier">_all</span><span class="special">()</span></code> member functions are convenient shortcuts
          to manipulate all settings simultaneously.
        </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="high_level_components.boost_python_docstring_options_h.example"></a><a class="link" href="boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.example" title="Example">Example</a>
</h3></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.example.docstring_options_defined_at_com">Docstring
          options defined at compile time</a></span></dt>
<dt><span class="section"><a href="boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.example.selective_suppressions">Selective
          suppressions</a></span></dt>
<dt><span class="section"><a href="boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.example.wrapping_from_multiple_c_scopes">Wrapping
          from multiple C++ scopes</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="high_level_components.boost_python_docstring_options_h.example.docstring_options_defined_at_com"></a><a class="link" href="boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.example.docstring_options_defined_at_com" title="Docstring options defined at compile time">Docstring
          options defined at compile time</a>
</h4></div></div></div>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">module</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">def</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">docstring_options</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>

<span class="keyword">void</span> <span class="identifier">foo</span><span class="special">()</span> <span class="special">{}</span>

<span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">demo</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">;</span>
    <span class="identifier">docstring_options</span> <span class="identifier">doc_options</span><span class="special">(</span><span class="identifier">DEMO_DOCSTRING_SHOW_ALL</span><span class="special">);</span>
    <span class="identifier">def</span><span class="special">(</span><span class="string">"foo"</span><span class="special">,</span> <span class="identifier">foo</span><span class="special">,</span> <span class="string">"foo doc"</span><span class="special">);</span>
<span class="special">}</span>
</pre>
<p>
            If compiled with <code class="computeroutput"><span class="special">-</span><span class="identifier">DDEMO_DOCSTRING_SHOW_ALL</span><span class="special">=</span><span class="keyword">true</span></code>:
          </p>
<pre class="programlisting"><span class="special">&gt;&gt;&gt;</span> <span class="identifier">import</span> <span class="identifier">demo</span>
<span class="special">&gt;&gt;&gt;</span> <span class="identifier">print</span> <span class="identifier">demo</span><span class="special">.</span><span class="identifier">foo</span><span class="special">.</span><span class="identifier">__doc__</span>
<span class="identifier">foo</span><span class="special">()</span> <span class="special">-&gt;</span> <span class="identifier">None</span> <span class="special">:</span> <span class="identifier">foo</span> <span class="identifier">doc</span>
<span class="identifier">C</span><span class="special">++</span> <span class="identifier">signature</span><span class="special">:</span>
    <span class="identifier">foo</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">-&gt;</span> <span class="keyword">void</span>
</pre>
<p>
            If compiled with <code class="computeroutput"><span class="special">-</span><span class="identifier">DDEMO_DOCSTRING_SHOW_ALL</span><span class="special">=</span><span class="keyword">false</span></code>:
          </p>
<pre class="programlisting"><span class="special">&gt;&gt;&gt;</span> <span class="identifier">import</span> <span class="identifier">demo</span>
<span class="special">&gt;&gt;&gt;</span> <span class="identifier">print</span> <span class="identifier">demo</span><span class="special">.</span><span class="identifier">foo</span><span class="special">.</span><span class="identifier">__doc__</span>
<span class="identifier">None</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="high_level_components.boost_python_docstring_options_h.example.selective_suppressions"></a><a class="link" href="boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.example.selective_suppressions" title="Selective suppressions">Selective
          suppressions</a>
</h4></div></div></div>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">module</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">def</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">args</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">docstring_options</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>

<span class="keyword">int</span> <span class="identifier">foo1</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">i</span><span class="special">;</span> <span class="special">}</span>
<span class="keyword">int</span> <span class="identifier">foo2</span><span class="special">(</span><span class="keyword">long</span> <span class="identifier">l</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="keyword">static_cast</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;(</span><span class="identifier">l</span><span class="special">);</span> <span class="special">}</span>
<span class="keyword">int</span> <span class="identifier">foo3</span><span class="special">(</span><span class="keyword">float</span> <span class="identifier">f</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="keyword">static_cast</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;(</span><span class="identifier">f</span><span class="special">);</span> <span class="special">}</span>
<span class="keyword">int</span> <span class="identifier">foo4</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">d</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="keyword">static_cast</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;(</span><span class="identifier">d</span><span class="special">);</span> <span class="special">}</span>

<span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">demo</span><span class="special">)</span>
<span class="special">{</span>
    <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">;</span>
    <span class="identifier">docstring_options</span> <span class="identifier">doc_options</span><span class="special">;</span>
    <span class="identifier">def</span><span class="special">(</span><span class="string">"foo1"</span><span class="special">,</span> <span class="identifier">foo1</span><span class="special">,</span> <span class="identifier">arg</span><span class="special">(</span><span class="string">"i"</span><span class="special">),</span> <span class="string">"foo1 doc"</span><span class="special">);</span>
    <span class="identifier">doc_options</span><span class="special">.</span><span class="identifier">disable_user_defined</span><span class="special">();</span>
    <span class="identifier">def</span><span class="special">(</span><span class="string">"foo2"</span><span class="special">,</span> <span class="identifier">foo2</span><span class="special">,</span> <span class="identifier">arg</span><span class="special">(</span><span class="string">"l"</span><span class="special">),</span> <span class="string">"foo2 doc"</span><span class="special">);</span>
    <span class="identifier">doc_options</span><span class="special">.</span><span class="identifier">disable_signatures</span><span class="special">();</span>
    <span class="identifier">def</span><span class="special">(</span><span class="string">"foo3"</span><span class="special">,</span> <span class="identifier">foo3</span><span class="special">,</span> <span class="identifier">arg</span><span class="special">(</span><span class="string">"f"</span><span class="special">),</span> <span class="string">"foo3 doc"</span><span class="special">);</span>
    <span class="identifier">doc_options</span><span class="special">.</span><span class="identifier">enable_user_defined</span><span class="special">();</span>
    <span class="identifier">def</span><span class="special">(</span><span class="string">"foo4"</span><span class="special">,</span> <span class="identifier">foo4</span><span class="special">,</span> <span class="identifier">arg</span><span class="special">(</span><span class="string">"d"</span><span class="special">),</span> <span class="string">"foo4 doc"</span><span class="special">);</span>
    <span class="identifier">doc_options</span><span class="special">.</span><span class="identifier">enable_py_signatures</span><span class="special">();</span>
    <span class="identifier">def</span><span class="special">(</span><span class="string">"foo5"</span><span class="special">,</span> <span class="identifier">foo4</span><span class="special">,</span> <span class="identifier">arg</span><span class="special">(</span><span class="string">"d"</span><span class="special">),</span> <span class="string">"foo5 doc"</span><span class="special">);</span>
    <span class="identifier">doc_options</span><span class="special">.</span><span class="identifier">disable_py_signatures</span><span class="special">();</span>
    <span class="identifier">doc_options</span><span class="special">.</span><span class="identifier">enable_cpp_signatures</span><span class="special">();</span>
    <span class="identifier">def</span><span class="special">(</span><span class="string">"foo6"</span><span class="special">,</span> <span class="identifier">foo4</span><span class="special">,</span> <span class="identifier">arg</span><span class="special">(</span><span class="string">"d"</span><span class="special">),</span> <span class="string">"foo6 doc"</span><span class="special">);</span>
<span class="special">}</span>
</pre>
<p>
            Python code:
          </p>
<pre class="programlisting"><span class="special">&gt;&gt;&gt;</span> <span class="identifier">import</span> <span class="identifier">demo</span>
<span class="special">&gt;&gt;&gt;</span> <span class="identifier">print</span> <span class="identifier">demo</span><span class="special">.</span><span class="identifier">foo1</span><span class="special">.</span><span class="identifier">__doc__</span>
<span class="identifier">foo1</span><span class="special">(</span> <span class="special">(</span><span class="keyword">int</span><span class="special">)</span><span class="identifier">i</span><span class="special">)</span> <span class="special">-&gt;</span> <span class="keyword">int</span> <span class="special">:</span> <span class="identifier">foo1</span> <span class="identifier">doc</span>
<span class="identifier">C</span><span class="special">++</span> <span class="identifier">signature</span><span class="special">:</span>
    <span class="identifier">foo1</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">)</span> <span class="special">-&gt;</span> <span class="keyword">int</span>
<span class="special">&gt;&gt;&gt;</span> <span class="identifier">print</span> <span class="identifier">demo</span><span class="special">.</span><span class="identifier">foo2</span><span class="special">.</span><span class="identifier">__doc__</span>
<span class="identifier">foo2</span><span class="special">(</span> <span class="special">(</span><span class="keyword">int</span><span class="special">)</span><span class="identifier">l</span><span class="special">)</span> <span class="special">-&gt;</span> <span class="keyword">int</span> <span class="special">:</span>
<span class="identifier">C</span><span class="special">++</span> <span class="identifier">signature</span><span class="special">:</span>
    <span class="identifier">foo2</span><span class="special">(</span><span class="keyword">long</span> <span class="identifier">l</span><span class="special">)</span> <span class="special">-&gt;</span> <span class="keyword">int</span>
<span class="special">&gt;&gt;&gt;</span> <span class="identifier">print</span> <span class="identifier">demo</span><span class="special">.</span><span class="identifier">foo3</span><span class="special">.</span><span class="identifier">__doc__</span>
<span class="identifier">None</span>
<span class="special">&gt;&gt;&gt;</span> <span class="identifier">print</span> <span class="identifier">demo</span><span class="special">.</span><span class="identifier">foo4</span><span class="special">.</span><span class="identifier">__doc__</span>
<span class="identifier">foo4</span> <span class="identifier">doc</span>
<span class="special">&gt;&gt;&gt;</span> <span class="identifier">print</span> <span class="identifier">demo</span><span class="special">.</span><span class="identifier">foo5</span><span class="special">.</span><span class="identifier">__doc__</span>
<span class="identifier">foo5</span><span class="special">(</span> <span class="special">(</span><span class="keyword">float</span><span class="special">)</span><span class="identifier">d</span><span class="special">)</span> <span class="special">-&gt;</span> <span class="keyword">int</span> <span class="special">:</span> <span class="identifier">foo5</span> <span class="identifier">doc</span>
<span class="special">&gt;&gt;&gt;</span> <span class="identifier">print</span> <span class="identifier">demo</span><span class="special">.</span><span class="identifier">foo6</span><span class="special">.</span><span class="identifier">__doc__</span>
<span class="identifier">foo6</span> <span class="identifier">doc</span>
<span class="identifier">C</span><span class="special">++</span> <span class="identifier">signature</span><span class="special">:</span>
    <span class="identifier">foo6</span><span class="special">(</span><span class="keyword">double</span> <span class="identifier">d</span><span class="special">)</span> <span class="special">-&gt;</span> <span class="keyword">int</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="high_level_components.boost_python_docstring_options_h.example.wrapping_from_multiple_c_scopes"></a><a class="link" href="boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.example.wrapping_from_multiple_c_scopes" title="Wrapping from multiple C++ scopes">Wrapping
          from multiple C++ scopes</a>
</h4></div></div></div>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">module</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">def</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">args</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">docstring_options</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>

<span class="keyword">int</span> <span class="identifier">foo1</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">i</span><span class="special">;</span> <span class="special">}</span>
<span class="keyword">int</span> <span class="identifier">foo2</span><span class="special">(</span><span class="keyword">long</span> <span class="identifier">l</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="keyword">static_cast</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;(</span><span class="identifier">l</span><span class="special">);</span> <span class="special">}</span>

<span class="keyword">int</span> <span class="identifier">bar1</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">i</span><span class="special">;</span> <span class="special">}</span>
<span class="keyword">int</span> <span class="identifier">bar2</span><span class="special">(</span><span class="keyword">long</span> <span class="identifier">l</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="keyword">static_cast</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;(</span><span class="identifier">l</span><span class="special">);</span> <span class="special">}</span>

<span class="keyword">namespace</span> <span class="special">{</span>

    <span class="keyword">void</span> <span class="identifier">wrap_foos</span><span class="special">()</span>
    <span class="special">{</span>
        <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">;</span>
        <span class="comment">// no docstring_options here</span>
        <span class="comment">//   -&gt; settings from outer C++ scope are in effect</span>
        <span class="identifier">def</span><span class="special">(</span><span class="string">"foo1"</span><span class="special">,</span> <span class="identifier">foo1</span><span class="special">,</span> <span class="identifier">arg</span><span class="special">(</span><span class="string">"i"</span><span class="special">),</span> <span class="string">"foo1 doc"</span><span class="special">);</span>
        <span class="identifier">def</span><span class="special">(</span><span class="string">"foo2"</span><span class="special">,</span> <span class="identifier">foo2</span><span class="special">,</span> <span class="identifier">arg</span><span class="special">(</span><span class="string">"l"</span><span class="special">),</span> <span class="string">"foo2 doc"</span><span class="special">);</span>
    <span class="special">}</span>

    <span class="keyword">void</span> <span class="identifier">wrap_bars</span><span class="special">()</span>
    <span class="special">{</span>
        <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">;</span>
        <span class="keyword">bool</span> <span class="identifier">show_user_defined</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">;</span>
        <span class="keyword">bool</span> <span class="identifier">show_signatures</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">;</span>
        <span class="identifier">docstring_options</span> <span class="identifier">doc_options</span><span class="special">(</span><span class="identifier">show_user_defined</span><span class="special">,</span> <span class="identifier">show_signatures</span><span class="special">);</span>
        <span class="identifier">def</span><span class="special">(</span><span class="string">"bar1"</span><span class="special">,</span> <span class="identifier">bar1</span><span class="special">,</span> <span class="identifier">arg</span><span class="special">(</span><span class="string">"i"</span><span class="special">),</span> <span class="string">"bar1 doc"</span><span class="special">);</span>
        <span class="identifier">def</span><span class="special">(</span><span class="string">"bar2"</span><span class="special">,</span> <span class="identifier">bar2</span><span class="special">,</span> <span class="identifier">arg</span><span class="special">(</span><span class="string">"l"</span><span class="special">),</span> <span class="string">"bar2 doc"</span><span class="special">);</span>
    <span class="special">}</span>
<span class="special">}</span>

<span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">demo</span><span class="special">)</span>
<span class="special">{</span>
    <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">docstring_options</span> <span class="identifier">doc_options</span><span class="special">(</span><span class="keyword">false</span><span class="special">);</span>
    <span class="identifier">wrap_foos</span><span class="special">();</span>
    <span class="identifier">wrap_bars</span><span class="special">();</span>
<span class="special">}</span>
</pre>
<p>
            Python code:
          </p>
<pre class="programlisting"><span class="special">&gt;&gt;&gt;</span> <span class="identifier">import</span> <span class="identifier">demo</span>
<span class="special">&gt;&gt;&gt;</span> <span class="identifier">print</span> <span class="identifier">demo</span><span class="special">.</span><span class="identifier">foo1</span><span class="special">.</span><span class="identifier">__doc__</span>
<span class="identifier">None</span>
<span class="special">&gt;&gt;&gt;</span> <span class="identifier">print</span> <span class="identifier">demo</span><span class="special">.</span><span class="identifier">foo2</span><span class="special">.</span><span class="identifier">__doc__</span>
<span class="identifier">None</span>
<span class="special">&gt;&gt;&gt;</span> <span class="identifier">print</span> <span class="identifier">demo</span><span class="special">.</span><span class="identifier">bar1</span><span class="special">.</span><span class="identifier">__doc__</span>
<span class="identifier">bar1</span> <span class="identifier">doc</span>
<span class="special">&gt;&gt;&gt;</span> <span class="identifier">print</span> <span class="identifier">demo</span><span class="special">.</span><span class="identifier">bar2</span><span class="special">.</span><span class="identifier">__doc__</span>
<span class="identifier">bar2</span> <span class="identifier">doc</span>
</pre>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2002-2005, 2015 David Abrahams, Stefan Seefeld<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost_python_def_visitor_hpp.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../high_level_components.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="boost_python_enum_hpp.html"><img src="../../images/next.png" alt="Next"></a>
</div>
</body>
</html>
